# Copyright 2013 the V8 project authors. All rights reserved.
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1.  Redistributions of source code must retain the above copyright
#     notice, this list of conditions and the following disclaimer.
# 2.  Redistributions in binary form must reproduce the above copyright
#     notice, this list of conditions and the following disclaimer in the
#     documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

This page tests handling of parentheses subexpressions.

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS regexp1.exec('abc') is ['ab','a','b']
PASS regexp2.exec('abacadabe') is ['abe','ab','b','b']
PASS regexp3.exec('abacadabe') is ['abe','ab','b',undefined]
PASS regexp4.exec('abacadabe') is ['abe','ab','b',undefined]
PASS regexp5.exec('abacadabe') is ['abe','ab','b','b',undefined,undefined]
PASS regexp6.exec('abcde') is ['ab','ab','b','b',undefined,undefined]
PASS regexp7.exec('abc') is ['abc','ab','b']
PASS regexp8.exec('bcaddxqy') is ['qy','q','q','y']
PASS regexp9.exec('asdfjejgsdflaksdfjkeljghkjea') is ['a','a',undefined]
PASS regexp10.exec('asdfjejgsdflaksdfjkeljghat') is ['at']
PASS regexp11.exec('Developing with JavaScript is dangerous, do not try it without assistance') is null
PASS regexp12.exec('Seattle, WA to Buckley, WA') is ['Seattle, WA to Buckley, WA', undefined, 'Seattle', 'WA', undefined, 'Buckley', 'WA']
PASS regexp13.exec('zxcasd;fl ^AaaAAaaaf;lrlrzs') is ['AaaAAaaaf;lrlrzs',undefined,'AaaAAaaaf;lrlrzs']
PASS regexp14.exec('b') is ['b',undefined,'b']
PASS regexp15.exec('abdf') is ['abdf',undefined,'abd','f']
PASS regexp16.exec('abc') is ['ab','a','b']
PASS regexp17.exec('bcaDxqy') is ['Dx','D']
PASS regexp18.exec('Hello: World') is ['Hello:',':']
PASS regexp19.exec('barrel') is ['bar','']
PASS regexp20.exec('barrel') is ['barrel','rel']
PASS regexp20.exec('2barrel') is ['2barrel','rel']
PASS regexp21.exec('abc') is ['ab','ab','b']
PASS regexp22.exec('abcdlskfgjdslkfg') is null
PASS regexp23.exec('<html xmlns="http://www.w3.org/1999/xhtml"') is ['"http://www.w3.org/1999/xhtml"']
PASS regexp24.exec('123') is null
PASS regexp25.exec('this is a test') is ['this','this',undefined]
PASS regexp25.exec('!this is a test') is null
PASS regexp26.exec('aaa') is ['aaa',undefined,undefined]
PASS regexp27.exec('file:///Users/Someone/Desktop/HelloWorld/index.html') is ['file:///Users/Someone/Desktop/HelloWorld/index.html','file','//','',undefined,undefined,undefined,'',undefined,'/Users/Someone/Desktop/HelloWorld/index.html',undefined,undefined]
PASS regexp28.exec('file:///Users/Someone/Desktop/HelloWorld/index.html') is ['file:','file',undefined,undefined,undefined,undefined,undefined]
PASS regexp29.exec('Committer:') is null
PASS regexp30.exec('Committer:') is null
PASS regexp31.exec('Committer:') is null
PASS regexp32.exec('Committer:') is null
PASS regexp33.exec('> <head>') is ['>',undefined,undefined,'>']
PASS regexp34.exec('xyz123') is null
PASS regexp34.exec('btn-abc') is ['btn-abc']
PASS regexp34.exec('btn- abc') is null
PASS regexp34.exec('XXbtn-abc') is null
PASS regexp34.exec('XX btn-abc') is ['btn-abc']
PASS regexp35.exec('ax') is ['ax','ax','a','x']
PASS regexp35.exec('axx') is null
PASS regexp35.exec('axxx') is ['axxx','axxx','a','xxx']
PASS regexp35.exec('bx') is ['bx','bx','b','x']
PASS regexp35.exec('bxx') is null
PASS regexp35.exec('bxxx') is ['bxxx','bxxx','b','xxx']
PASS regexp36.exec('/2011') is ['/2011','/2011','/','2011']
PASS regexp36.exec('/11') is ['/11','/11','/','11']
PASS regexp36.exec('/123') is null
PASS regexp37.exec('7/4/1776') is ['7/4/1776','7','/','4','/1776','/','1776']
PASS regexp37.exec('07-04-1776') is ['07-04-1776','07','-','04','-1776','-','1776']
PASS regexp38.exec('xx') is ['xx','xx','xx']
PASS regexp38.exec('b') is ['b','b',undefined]
PASS regexp38.exec('z') is ['z','z',undefined]
PASS regexp38.exec('') is ['','',undefined]
PASS regexp39.exec('') is ['',undefined,undefined]
PASS regexp39.exec('8') is ['8','8',undefined]
PASS regexp39.exec('zP') is ['',undefined,undefined]
PASS regexp40.exec('') is ['',undefined,undefined,undefined,'']
PASS regexp40.exec('8') is ['8','8','8',undefined,'']
PASS regexp40.exec('zPz') is ['',undefined,undefined,undefined,'']
PASS regexp40.exec('zPPz') is ['',undefined,undefined,undefined,'']
PASS regexp40.exec('zPPPz') is ['',undefined,undefined,undefined,'']
PASS regexp40.exec('zPPPPz') is ['',undefined,undefined,undefined,'']
PASS regexp41.exec('Here is a link: http://www.acme.com/our_products/index.html. That is all we want!') is ['http://www.acme.com/our_products/index.html','http://www.acme.com/our_products/index.html','http://','l',undefined]
PASS regexp42.exec('') is ['',undefined,undefined]
PASS regexp42.exec('4') is ['4','4','4']
PASS regexp42.exec('4321') is ['4','4','4']
PASS /(?!(?=r{0}){2,})|((z)?)?/gi.test('') is true
PASS regexp43.exec('SSS') is ['']
PASS regexp44.exec('SSS') is ['',undefined]
PASS regexp45.exec('vt') is null
PASS regexp46.exec('5') is null
PASS regexp46.exec('pk') is ['pk',undefined,undefined]
PASS regexp46.exec('Xw555') is ['w555','w',undefined]
PASS regexp46.exec('Xw55pk5') is ['w','w','']
PASS regexp47.exec('/www.acme.com/this/is/a/path/file.txt') is ['/www.acme.com/this/is/a/path/file.txt','/www.acme.com/this/is/a/path/file.txt',undefined]
PASS regexp48.exec('http://www.acme.com/this/is/a/path/file.txt') is ['http://www.acme.com/this/is/a/path/file.txt','http','www.acme.com',undefined,'this/is/a/path/file.txt',undefined,undefined]
PASS regexp49.exec('http://www.acme.com/this/is/a/path/file.txt') is ['http://www.acme.com/this/is/a/path/file.txt',undefined,undefined,'http','www.acme.com',undefined,'this/is/a/path/file.txt',undefined,undefined]
PASS regexp50.exec('((a)b{28,}c|d)x') is null
PASS regexp50.exec('abbbbbbbbbbbbbbbbbbbbbbbbbbbbcx') is ['abbbbbbbbbbbbbbbbbbbbbbbbbbbbcx', 'abbbbbbbbbbbbbbbbbbbbbbbbbbbbc', 'a']
PASS regexp50.exec('dx') is ['dx', 'd', undefined]
PASS regexp51.exec('abc') is null
PASS regexp51.exec(s) is ['){-,}P{Any}',')',undefined]
PASS 'Hi Bob'.match(regexp52) is ['Bob',undefined,'Bob',undefined,undefined]
PASS regexp53.exec('#') is ['',undefined,'']
PASS regexp54.exec('#') is ['','',undefined,undefined,'']
PASS regexp55.exec('#') is ['','']
PASS regexp56.exec('a') is ['','']
PASS regexp57.exec('a') is ['a','a']
PASS regexp58.exec('badbc') is ['a']
PASS 'Y aaa X Match1 Y aaa Y Match2 Z'.match(regexp59) is ['X Match1 Y','Y Match2 Z']
PASS successfullyParsed is true

TEST COMPLETE

